
local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddDynamicShadow()
    inst.entity:AddNetwork()

    MakeCharacterPhysics(inst, 50, .5)

    inst.DynamicShadow:SetSize(1.5, .75)
    inst.Transform:SetFourFaced()

    -- inst:AddTag("character")
    -- inst:AddTag("pig")
    -- inst:AddTag("scarytoprey")
    inst:AddTag("pigman_npc")
    inst:AddTag("npc")


    inst.AnimState:SetBank("pigman")
    inst.AnimState:PlayAnimation("idle_loop", true)
    inst.AnimState:Hide("hat")

    inst.talk_sound = "dontstarve/pig/grunt"
    inst:AddComponent("talker")
    -- inst.components.talker.fontsize = 35
    -- inst.components.talker.font = TALKINGFONT
    -- --inst.components.talker.colour = Vector3(133/255, 140/255, 167/255)
    -- inst.components.talker.offset = Vector3(0, -400, 0)
    -- inst.components.talker:MakeChatter()


    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("npc_base_lib")
    inst:AddComponent("npc_everything_data")

    --Remove these tags so that they can be added properly when replicating components below


    inst:AddComponent("locomotor") -- locomotor must be constructed before the stategraph
    inst.components.locomotor.runspeed = TUNING.PIG_RUN_SPEED --5
    inst.components.locomotor.walkspeed = TUNING.PIG_WALK_SPEED --3

    -- inst:AddComponent("bloomer")

    -- ------------------------------------------
    -- inst:AddComponent("eater")
    -- inst.components.eater:SetDiet({ FOODGROUP.OMNI }, { FOODGROUP.OMNI })
    -- inst.components.eater:SetCanEatHorrible()
    -- inst.components.eater:SetCanEatRaw()
    -- inst.components.eater:SetStrongStomach(true) -- can eat monster meat!
    -- inst.components.eater:SetOnEatFn(OnEat)
    -- ------------------------------------------
    inst:AddComponent("health")
    inst:AddComponent("combat")
    inst.components.combat.hiteffectsymbol = "pig_torso"



    MakeMediumBurnableCharacter(inst, "pig_torso")

    inst:AddComponent("named")

    inst:AddComponent("lootdropper")

    MakeMediumFreezableCharacter(inst, "pig_torso")

    ------------------------------------------
    inst:AddComponent("follower")
    -- inst:AddComponent("inspectable")
    ------------------------------------------

    inst:SetStateGraph("SGpig")


    return inst
end






 

local function Fn()
    local Fx = Class()

    function Fx:Common_Npc_Create()
        local ret = fn()
        return ret
    end


    return Fx
end

return Fn